<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>产品详情 - API测试</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        .container {
            max-width: 800px;
            margin-top: 2rem;
        }
        .card {
            margin-bottom: 2rem;
        }
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .detail-item {
            margin-bottom: 1rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid #eee;
        }
        .detail-label {
            font-weight: bold;
            color: #666;
        }
        .product-image {
            max-width: 200px;
            border-radius: 4px;
            margin-top: 0.5rem;
        }
        .status-badge {
            padding: 0.25rem 0.5rem;
            border-radius: 4px;
            font-weight: bold;
        }
        .status-on {
            background-color: #c3e6cb;
            color: #155724;
        }
        .status-off {
            background-color: #f8d7da;
            color: #721c24;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="card">
            <div class="card-header">
                <h2>产品详情</h2>
                <div>
                    <a href="edit.html?id={{id}}" class="btn btn-primary btn-sm">编辑</a>
                    <button class="btn btn-danger btn-sm ms-2" id="deleteBtn">删除</button>
                    <a href="list.html" class="btn btn-secondary btn-sm ms-2">返回列表</a>
                </div>
            </div>
            <div class="card-body">
                <div class="detail-item">
                    <div class="detail-label">ID</div>
                    <div id="productId">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">产品名称</div>
                    <div id="productName">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">分类ID</div>
                    <div id="categoryId">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">价格</div>
                    <div id="productPrice">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">是否上架</div>
                    <div id="isOnSale"><span class="status-badge">加载中...</span></div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">产品描述</div>
                    <div id="productDescription">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">封面图</div>
                    <img id="productImage" class="product-image" alt="产品图片">
                </div>
                <div class="detail-item">
                    <div class="detail-label">创建时间</div>
                    <div id="createdAt">加载中...</div>
                </div>
                <div class="detail-item">
                    <div class="detail-label">更新时间</div>
                    <div id="updatedAt">加载中...</div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script type="module" src="../js/api.js"></script>
    <script type="module" src="js/detail.js"></script>
</body>
</html>